//============================================================================================
/**
 * @file	result_data.h
 * @brief	結果データ
 * @author	Nozomu Saito
 */
//============================================================================================
#ifndef __RESULT_DATA_H__
#define __RESULT_DATA_H__

typedef struct RESULT_tag * RSLT_PTR;

#include "common.h"
#include "strbuf.h"
#include "pokethlon.h"

#define RECORD_STR_LEN	(18*2+1)	//日本語６文字+EOM

typedef struct RESULT_DATA_tag
{
	int NetID;
	u16 MonsNo;
	u16 Form;
	u8  PokeIdx;	//0〜2	ポケ単位ではなくプレーヤー単位に結果を持つことになったので、これは未使用になりました
	u8	Rank;
	u16 Score;
	int RecordOrg;
	STRBUF *Record;
	STRBUF *NickName;
}RESULT_DATA;


typedef enum{
	SORT_SCORE,
	SORT_REC_LARGE,
	SORT_REC_SMALL,
}SORT_CODE;

typedef enum{
	SORT_TYPE_NONE,
	SORT_TYPE_LARGE,
	SORT_TYPE_SMALL,
}SORT_TYPE;

extern RSLT_PTR RSLT_Alloc(const int inHeapID);

extern void RSLT_Free(RSLT_PTR ptr);

extern RESULT_DATA *RSLT_GetEntryResultData(RSLT_PTR ptr);

extern void RSLT_ResetEntryResultData(RSLT_PTR ptr);

extern void RSLT_Sort(RSLT_PTR ptr, const SORT_CODE inCode);
extern RESULT_DATA *RSLT_GetResultData(RSLT_PTR ptr, const u8 inIndex);
extern RESULT_DATA *RSLT_GetResultDataPtr(RSLT_PTR ptr, const u8 inIndex);

extern void RSLT_SetupEx(RSLT_PTR ptr, const int inDataNum, const BOOL inIconValid);
extern void RSLT_Setup(RSLT_PTR ptr);
extern int RSLT_GetDataNum(RSLT_PTR ptr);
extern BOOL RSLT_IsValidPokeIcon(RSLT_PTR ptr);
extern void RSLT_AddTotalScore(RSLT_PTR ptr);
extern int RSLT_GetTotalScore(RSLT_PTR ptr, const int inNetID);
extern void RSLT_SetEvtScore(RSLT_PTR ptr, const int inEvtIdx);
extern int RSLT_GetEvtScore(RSLT_PTR ptr, const int inEvtIdx, const int inNetID);
#if 0
extern void RSLT_SetResultEx(	PKTHLN_PTR work, RSLT_PTR ptr,
								const int inNetID, const u8 inEntryNo,
								const int inRecordOrg,
								const u8 inReg, const u8 inDigit, const int inMsgID );
#endif
extern void RSLT_SetResult(	PKTHLN_PTR work, RSLT_PTR ptr,
							const int inNetID, const int inRecordOrg,
							const u8 inReg, const u8 inDigit, const int inMsgID );
extern void RSLT_SetResult2(PKTHLN_PTR work, RSLT_PTR ptr, const int inNetID, const u16 inRecordOrg,
						const int inRec1, const int inRec2,
						const u8 inReg1, const u8 inReg2,
						const u8 inDigit1, const u8 inDigit2, const int inMsgID );

#endif 	//__RESULT_DATA_H__